use "C:\Users\jkbrueck\Documents\STATA\Fuel 4\US data\Calvin3.dta", clear

forvalues i = 1991(1)2019 {
gen yy`i' = y`i'
replace y`i' = "A" if y`i' == "AM" | y`i' == "UN" | y`i' == "DL" | ///
y`i' == "JB" | y`i' == "AK" | y`i' == "SW"
}

*"A" denotes focal carrier, as in Calvin1 and Calvin2 data sets

gen airline = "."
replace airline = "AA" if yy2014 == "AM"
replace airline = "UA" if yy2014 == "UN"
replace airline = "WN" if yy2014 == "SW"
replace airline = "B6" if yy2014 == "JB"
replace airline = "AS" if yy2014 == "AK"
replace airline = "DL" if yy2014 == "DL"

gen ct5 = 0
forvalues i = 1991(1)2018 {
local j = `i' + 1
replace ct5 = ct5 + 1  if y`i' == "S" & (y`j' == "A" | y`j' == "D" | y`j' == "O" | y`j' == "C") 
}

drop if ct5 > 0

*drops histories where scrappage (S) is followed by reuse

save "C:\Users\jkbrueck\Documents\STATA\Fuel 4\US data\Calvin3_A_car.dta", replace




